﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace SeaBattle.Domain.Entities
{
    /// <summary>
    /// Class Ship
    /// </summary>
    public class Ship
    {
        private List<ShipPart> parts = new List<ShipPart>();

        /// <summary>
        /// Initializes a new instance of the <see cref="Ship"/> class.
        /// </summary>
        /// <param name="partsCount">The parts count.</param>
        public Ship(byte partsCount)
        {
            InitializeShip(partsCount);
        }

        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        /// <value>
        /// The id.
        /// </value>
        public int Id { get; set; }

        /// <summary>
        /// Initializes the ship.
        /// </summary>
        /// <param name="partsCount">The parts count.</param>
        private void InitializeShip(byte partsCount)
        {
            for (byte i = 0; i < partsCount; i++)
            {
                parts.Add(new ShipPart(this));
            }
        }

        /// <summary>
        /// Gets the parts.
        /// </summary>
        public IList<ShipPart> Parts { get { return parts.AsReadOnly(); } }

        /// <summary>
        /// Gets the parts count.
        /// </summary>
        public int PartsCount { get { return parts.Count; } }
    }
}
